function roleMenuDialog(
    {
        roleId,
        title,
        roleSign,
        callback = Function()
    }
) {

    const developerFlag = roleSign === "developer";

    let menuTree = null;
    const $menuTree = getMenuTree({
        callback(zTree) {
            menuTree = zTree;
            //开发者默认全部菜单，不做编辑
            if (developerFlag) {
                return;
            }

            const setting = zTree.setting;
            setting.check = {
                ...setting.check,
                enable: true
            }
            zTree.refresh();

            const nodes = zTree.transformToArray(zTree.getNodes());

            queryMenuList({
                roleId
            }, ({Result = []}) => {

                Result.forEach(({menuId}) => {
                    nodes.forEach(node => {
                        if (node.id === menuId) {
                            zTree.checkNode(node, true, false)
                        }
                    })
                })

            })
        }
    });

    const $content = $(`<div style="overflow: auto;max-height: 400px"></div>`);
    $content.html($menuTree);

    const $dialogWidget = $.dialog($content, {
        title: title,
        width: "400px",
        ok: developerFlag ? null : () => {
            if (!menuTree) {
                return $.toast("菜单未加载");
            }

            const checkedNodes = menuTree.getCheckedNodes(true);
            const menuIdList = checkedNodes.map(item => item.id);


            addOrUpdRoleMenu({
                roleId,
                menuIds: menuIdList.join(",")
            }, ({Code, Message}) => {
                if (Code !== 10000) {
                    return $.toast(Message);
                }

                $dialogWidget.remove();
                $.toast("编辑成功");
                callback();
            })

            return false;
        }
    })

    function addOrUpdRoleMenu(param, callback = Function()) {
        return $.sApi({
            data: param,
            url: "/api/RoleMenu/addOrUpdRoleMenu",
        }, callback)
    }

    function queryMenuList(param, callback = Function()) {
        return $.sApi({
            data: param,
            url: "/api/Menu/queryMenuList",
        }, callback)
    }
}